package com.ttsx.controller;

import com.ttsx.pojo.entity.UserAddress;
import com.ttsx.service.UserAddressService;
import com.ttsx.core.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wb
 * @since 2025-03-03
 */

@RestController
@RequestMapping("addr")
public class UserAddressController {

    @Autowired
    private UserAddressService userAddressService;


    @GetMapping("get/{id}")
    public Result<?> getById(@PathVariable("id") Long id){
        return Result.success(userAddressService.getById(id));
    }

    @PostMapping("save")
    public Result<?> save(@RequestBody UserAddress userAddress){
        return userAddressService.save(userAddress) ? Result.success() : Result.failure();
    }

    @PostMapping("update")
    public Result<?> update(@RequestBody UserAddress userAddress){
        return userAddressService.updateById(userAddress) ? Result.success() : Result.failure();
    }
}
